package com.ctvit.sjk.knowledge.app.controller;

import com.ctvit.sjk.knowledge.app.pojo.dto.AppChatRecordVoteDTO;
import com.ctvit.sjk.knowledge.app.service.ITabAppChatRecordService;
import com.ctvit.sjk.knowledge.core.controller.KnowledgeController;
import com.ctvit.sjk.knowledge.core.page.TableRecordInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;

/**
 * 应用聊天记录Controller
 *
 * @author heyingcheng
 * @date 2025/3/22
 */
@RestController
@RequestMapping("knowledge/application")
public class TabAppChatRecordController extends KnowledgeController {

    private final ITabAppChatRecordService tabAppChatRecordService;

    public TabAppChatRecordController(ITabAppChatRecordService tabAppChatRecordService) {
        this.tabAppChatRecordService = tabAppChatRecordService;
    }

    /**
     * 查询应用聊天记录列表
     */
    @GetMapping("{appId}/chat/{chatId}/client/{pageNum}/{pageSize}")
    public TableRecordInfo list(@PathVariable String appId,
                                @PathVariable String chatId,
                                @PathVariable int pageNum,
                                @PathVariable int pageSize) {
        return getRecordTable(Collections.emptyList(), pageNum, pageSize);
    }

    /**
     * 聊天记录投票
     */
    @PutMapping("{appId}/chat/{chatId}/chat_record/{recordId}/vote")
    public AjaxResult vote(@PathVariable String appId,
                           @PathVariable String chatId,
                           @PathVariable String recordId,
                           @RequestBody AppChatRecordVoteDTO dto) {
        return toAjax(tabAppChatRecordService.vote(appId, chatId, recordId, dto, CREATE_ID));
    }

}
